﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WooCoo.DataPortal
{
    /// <summary>
    /// 服务端数据门户需要继承的接口.    
    /// </summary>
    public interface IDataPortalServer
    {
        /// <summary>
        /// 创建一个业务对象
        /// </summary>
        /// <param name="objectType">业务对象类型</param>
        /// <param name="criteria">条件参数</param>
        /// <param name="context">
        /// <see cref="Server.DataPortalContext" />传递到服务器的上下文信息</param>
        /// <returns></returns>        
        DataPortalResult Create(object obj, DataPortalContext context);
        /// <summary>
        /// 取得业务对象.
        /// </summary>
        /// <param name="objectType">指定的业务对象类型.</param>
        /// <param name="criteria">过滤器.</param>
        /// <param name="context">
        /// <see cref="DataPortal.DataPortalContext" />传递到服务器的上下文信息.
        /// </param>
        DataPortalResult Fetch(Type objectType, object criteria, DataPortalContext context);
        /// <summary>
        /// 更新业务对象,对于Entity实体的调用本方法时，将自动根据数据状态选择数据操作。
        /// </summary>
        /// <param name="obj">需要更新的业务对象实例.</param>
        /// <param name="context">
        /// <see cref="DataPortal.DataPortalContext" />传递到服务器的上下文信息.
        /// </param>
        DataPortalResult Update(object obj, DataPortalContext context);
        /// <summary>
        /// 删除业务对象
        /// </summary>
        /// <param name="objectType">指定的业务对象类型.</param>
        /// <param name="criteria">过滤器.</param>
        /// <param name="context">
        /// <see cref="DataPortal.DataPortalContext" />传递到服务器的上下文信息.
        /// </param>
        DataPortalResult Delete(Type objectType, object criteria, DataPortalContext context);
        /// <summary>
        /// 非CFUD方式的方法执行
        /// </summary>
        /// <param name="requestMethod">
        /// <see cref="WooCoo.DataPortal.ActionInfo"/>命令执行的方法信息
        /// </param>
        /// <param name="context">
        /// <see cref="DataPortal.DataPortalContext" />传递到服务器的上下文信息.
        /// </param>
        /// <returns></returns>
        DataPortalResult Execute(object target, ActionInfo requestMethod, DataPortalContext context);
    }
}
